// JavaScript Document

$(function(){
	int_nav();
})

function int_fontsize(){
	var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
    var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
    var fontSize = Math.min(w, h) / 32;
    if (fontSize > 16) {
        fontSize = 16;
    }
    document.getElementsByTagName('html')[0].setAttribute("style", "font-size:" + fontSize + "px");
}

function int_nav(){
	$('.user').click(function(){
		$('.userinfo').toggle();
	});
	$('.normallanguage').click(function(){
		$('.normallanguage .languagelist').toggle();
	})
}

//checknav
function checknav(idname){
	$(idname).find('.checknav a').each(function(index){
		$(this).click(function(){
		  $(idname).find('.checknav a').removeClass('curr');
		  $(this).addClass('curr');
		  $(idname).find('.checkcon').hide();
		  $(idname).find('.checkcon').eq(index).show();
		})
	})	
}
//更多筛选；
//
function showmoreselect(btnid){
	var $btn=$(btnid);
	var showindex=false;
	$btn.click(
		function()
		{
			if(!showindex){
				$btn.find('ul').css({'height':'auto'});
				showindex=true;	
			}
			else{
				$btn.find('ul').css({'height':'40px'});
				showindex=false;	
			}
			
		})
 

}

//筛选；
//
function showmoreselect2(btnid,selectshowid){
	var $btn=$(btnid);
	var $show=$(selectshowid);
	var showindex=false;
	$btn.click(function()
		{
			if(!showindex){
				$(this).addClass('curr');
				$show.show();
				showindex=true;		
			}
			else{
				$(this).removeClass('curr');
				$show.hide();
				showindex=false;	
			}
		})
}
//chosemorebtn
//
//招聘信息这点
//
function showhrcon(){
	$('.hrlist .tit').each(function(index){
		$(this).toggle(function(){
			$(this).parent().find('.hrcon').slideDown();
		},function(){
			$(this).parent().find('.hrcon').hide();
		})
	})
}
/*****************************/
//幻灯；

 function showfocus(idname,autotype){
 	/** 切换目标索引**/
	var pic_index;
	/** 轮播计时**/
	var  timer=null;
	var pic_size = $(idname).find('.checkpic').size();
	var $checkpic = $(idname).find('.checkpic');
	var $picshow = $(idname).find('.picshow');
	var $checkpic_a = $(idname).find('.focusbtns a');
	var $leftarr=$(idname).find('a.arr_left');
	var $rightarr=$(idname).find('a.arr_right');
	if($(idname+' .scroll').size()>0){
		var scrollwidth=(parseInt($checkpic_a.width())+8)*$checkpic_a.size()+'px';
		$('.scroll').css('width',scrollwidth);
	}
	pic_index=0;
	slider();	
	
	function slider(){
		if (pic_index ===pic_size){pic_index = 0;}
		$checkpic.hide();	
		$checkpic.eq(pic_index).fadeIn();	
		$checkpic_a.removeClass('curr');
		$checkpic_a.eq(pic_index).addClass('curr');
		pic_index++;
		if(autotype!=='noauto'){
		timer=setTimeout(function(){slider();}, 5000);
		}

	};
	$checkpic_a.each(function(pindex){
		$(this).click(function(){
			pic_index=pindex;
			clearTimeout(timer);
			slider();	
		})	
	});
	$checkpic.each(function(pcindex){
		$(this).hover(function(){
			clearTimeout(timer);	
		},function(){
			timer=setTimeout(function(){slider();}, 5000);
		})	
	});
	$leftarr.click(function(){
		if ((pic_index-1) ===0){pic_index =pic_size-1;}
		else {pic_index=pic_index-2;}
		clearTimeout(timer);
		slider();	
	})	
	$rightarr.click(function(){
		clearTimeout(timer);
		slider();	
	})	

}

/*****************************/
//幻灯；
/** 切换目标索引**/
var al_index,
/** 轮播计时**/
 timer=null;
 function showanli(idname,autotype){
	var pic_size = $(idname).find('.checkpic').size();
	var $checkpic = $(idname).find('.checkpic');
	var $picshow = $(idname).find('.picshow');
	var $checkpic_a = $(idname).find('.focusbtns a');
	var $leftarr=$(idname).find('a#arr_left');
	var $rightarr=$(idname).find('a#arr_right');
	if($(idname+' .scroll').size()>0){
		var scrollwidth=(parseInt($checkpic_a.width())+8)*$checkpic_a.size()+'px';
		$('.scroll').css('width',scrollwidth);
	}
	al_index=0;
		slider();	
	
	function slider(){
		if (al_index ===pic_size-1){$rightarr.hide();}
		else{$rightarr.show();}
		if (al_index ===0){$leftarr.hide();}
		else{$leftarr.show();}
		$checkpic.hide();	
		$checkpic.eq(al_index).fadeIn();	
		$checkpic_a.removeClass('curr');
		$checkpic_a.eq(al_index).addClass('curr');
		al_index++;
		if(autotype=='auto'){
		timer=setTimeout(function(){slider();}, 4000);
		}

	};
	$checkpic_a.each(function(pindex){
		$(this).click(function(){
			al_index=pindex;
			clearTimeout(timer);
			slider();	
		})	
	});
	$leftarr.click(function(){
		if ((al_index-1) ===0){al_index =pic_size-1;}
		else {al_index=al_index-2;}
		clearTimeout(timer);
		slider();	
	})	
	$rightarr.click(function(){
		clearTimeout(timer);
		slider();	
	})	

}

/*****************************/
//输入框控件
function inputcheck(inputidname){
	var intval=$(inputidname).attr('value');
	$(inputidname).focus(function(){
			if($(inputidname).attr('value')==intval){
				$(inputidname).attr('value','');
			}
			$(inputidname).addClass('curr');
		})
		$(inputidname).blur(function(){
		   if($(inputidname).attr('value')==''){
				$(inputidname).attr('value',intval);
				$(inputidname).removeClass('curr');
			}

		});  
}
/*****************************/
//计算器
/** 切换套餐**/
function  autocalculator(idname){
	var $tc_list=$(idname).find('.tccheck li');
	var $tc_listcurr=$(idname).find('.tccheck li.curr');
	var tc_size = $tc_list.size();
	var $areaval = $(idname).find('input.itext');
	var $calcuval = $(idname).find('.zdjs');
	var $prev=$(idname).find('a.prev');
	var $next=$(idname).find('a.next');	
	var tc_index=0;
	autocalcu();
	$next.click(function(){
		if((tc_size>1)&(tc_index<tc_size-1)){
			tc_index++;
			$prev.removeClass('first');
			$tc_list.removeClass('curr');
			$tc_list.eq(tc_index).addClass('curr');
			$tc_list.hide();
			$tc_list.eq(tc_index).show();
			if(tc_index==tc_size-1){
				$next.addClass('last');
			}
			autocalcu();	
		}
		
	})

	$prev.click(function(){
		if((tc_size>1)&(tc_index>0)){
			tc_index--;
			$next.removeClass('last');
			$tc_list.removeClass('curr');
			$tc_list.eq(tc_index).addClass('curr');
			$tc_list.hide();
			$tc_list.eq(tc_index).show();
			if(tc_index==0){
				$prev.addClass('first');
			}	
			autocalcu();
		}
		
	})
	//自动计算
	function autocalcu(){

			if(checkNumber($areaval.val())){
				var calcuval=parseInt($areaval.val())*parseInt($tc_list.eq(tc_index).find('em').text())/10000;
				$calcuval.html(calcuval+' 万元')
			}
		$areaval.focus(function(){
			if($areaval.val()=="建筑面积"){
				$areaval.val('');
				$areaval.addClass('curr');
			}
		})
		$areaval.keyup(function(){
			console.log($areaval.val())
		    if(checkNumber($areaval.val())){
				var calcuval=parseInt($areaval.val())*parseInt($tc_list.eq(tc_index).find('em').text())/10000;
				$calcuval.text(calcuval+' 万元')
			}
			else{$areaval.val('建筑面积');$areaval.removeClass('curr');}
		});  
	}

	//验证字符串是否是数字  
	function checkNumber(theObj) {  
	    var reg = /^[0-9]+.?[0-9]*$/;  
	    if (reg.test(theObj)) {  
	        return true;  
	    }  
	    return false;  
	} 

}
//切换套餐
///** 切换套餐**/
function  autocheck(idname){
	var $tc_list=$(idname).find('li');
	var $tc_listcurr=$(idname).find('li.curr');
	var tc_size = $tc_list.size();
	var $prev=$(idname).find('a.prev');
	var $next=$(idname).find('a.next');	
	var tc_index=0;
	$next.click(function(){
		if((tc_size>1)&(tc_index<tc_size-1)){
			tc_index++;
			$prev.removeClass('first');
			$tc_list.removeClass('curr');
			$tc_list.eq(tc_index).addClass('curr');
			$tc_list.hide();
			$tc_list.eq(tc_index).show();
			if(tc_index==tc_size-1){
				$next.addClass('last');
			}
		}
		
	})

	$prev.click(function(){
		if((tc_size>1)&(tc_index>0)){
			tc_index--;
			$next.removeClass('last');
			$tc_list.removeClass('curr');
			$tc_list.eq(tc_index).addClass('curr');
			$tc_list.hide();
			$tc_list.eq(tc_index).show();
			if(tc_index==0){
				$prev.addClass('first');
			}	
		}
		
	})
}
//FLASH 载入
function flashshow(flashsrc,flashid,width,height){
	var so = new SWFObject(flashsrc, "mymovie", width, height, "8", "");
   so.addParam("wmode", "transparent");
   so.addParam("allowFullScreen", "true");
   so.addParam("base", ".");
   so.write(flashid);	
}



//弹框；

function tk_show(idname){
    var g = document.documentElement.scrollTop || document.body.scrollTop;
    $(idname).css("top", g);
	
    var window_height = $(window).height();
    var top = (parseInt(window_height) - parseInt($(idname).height())) / 2 + "px";
    $(idname).css("margin-top", top);
    $(idname).show();
    $(".blackbg").show();
	$(".blackbg").css("height", $('body').height());
}

function tk_hide(idname){
	$(idname).hide();
	$('.blackbg').hide();


}
//初始化图片
var changeimgsize = function (idname, maxwidth)
{
    var $idname = idname;
    var maxwidth = maxwidth;
    $($idname).each(function (i)
    {
        var imgsrc = $($idname).eq(i).attr("src")
        var img_op = document.createElement("img");
        img_op.onload = function ()
        {
            var img_width = img_op.width;
            var img_height = img_op.height;
            var img_theight, img_twidth;
            if (parseInt(img_width) <= maxwidth)
            {
                img_theight = img_height;
                img_twidth = img_width;
            }
            else
            {
                img_twidth = maxwidth + "px"
                img_theight = (parseInt(img_height) / parseInt(img_width)) * maxwidth + "px";
                ;
            }
            $($idname).eq(i).css({ "width": img_twidth, "height": img_theight});
        }
        img_op.src = imgsrc;
    })
}

function show_pic(img_list_array){
	var picshow_id='#rzshow',
	picshow_close='#rzshow a.close',
	picshow_im='#rzshow .img',
	picshow_img='#rzshow .img img',
	picshow_point,
	arr_left='#rzshow #arr_left',
	arr_right='#rzshow #arr_right',
	a_zy='#zybtn',
	mask='.blackbg',
	curr_index=0;
	var m_top;
	var g=document.documentElement.scrollTop+document.body.scrollTop;
	var picshow_t = ( $(window).height()/2);
	var picshow_h =  $(window).height();
	var picshow_top = (picshow_t+450*(-1)/2) + "px";	
	$(picshow_im).css({top:picshow_top,width: '705px',height: '475px'}) ;

	$(picshow_id).show();
	$(arr_left).hide();
	$(arr_right).hide();
	showpic(curr_index);
	
	function showpic(idnum){
				var imgsrc = img_list_array[idnum];
				var img_op =document.createElement("img"); 
				img_op.onload = function(){					
					  var img_width = img_op.width; 
					  var img_height = img_op.height;
					  var img_theight,img_twidth;
					 
					  var picshow_height=parseInt(img_theight)+70+'px';
					  var g=document.documentElement.scrollTop+document.body.scrollTop;
					  
					  var blackbgh = document.documentElement.scrollHeight;
   					  $(mask).css("height", blackbgh).show();
					  $(picshow_id).animate({ 
												top: g,
												height:picshow_h
											  }, 10 ,function(){
											  		$('#rzshow .tag-point').remove();
											  		var taglength=$('.imgs').eq(idnum).find('.tag-point').length;
											  		for(i=0;i<taglength;i++){
											  			$('.imgs').eq(idnum).find('.tag-point').eq(i).clone().appendTo('#rzshow .img');;
											  			tagbindhover();

											  		}
                       							   $(picshow_img).attr("src",imgsrc);
					                               if (idnum == 0){$(arr_left).hide();$(arr_right).show();}
					                               if (idnum > 0){$(arr_left).show();}
					                               if (idnum < (img_list_array.length-1)){$(arr_right).show();}
					                               if (idnum === (img_list_array.length-1)){$(arr_right).hide();}
					  							   if(img_list_array.length<=1){ $(arr_left).hide();$(arr_right).hide(); }

                   								 });					
					}
				img_op.src = imgsrc;			
	};
	$(picshow_close).click(function(){
		$(picshow_id).hide();	
		 $(mask).hide();
	});

	$(arr_left).click(function(){
		curr_index--;
		showpic(curr_index);
	})

	$(arr_right).click(function(){
		curr_index++;
		showpic(curr_index);
	})
}

